﻿package 
{
    import WorldNotice.*;
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import flash.utils.*;

    public class WorldNotice extends MovieClip implements IWorldNotice
    {
        public var _Notice:MovieClip;
        public var _NoticeText:TextField;
        private var _timer:Timer;
        private var _aryMessage:Array;
        private var blnEnterFrame:Boolean = false;
        private var _speed:Number = 0.035;
        private var _angle:Number = 0;
        private var _num:Number;
        private var _wait:Number = 2;
        private var _onClose:Function;

        public function WorldNotice() : void
        {
            this._timer = new Timer(100);
            this._aryMessage = [];
            this._onClose = new Function();
            this._Notice.alpha = 0;
            this._NoticeText.alpha = 0;
            this.mouseChildren = false;
            this.mouseEnabled = false;
            return;
        }// end function

        public function get content() : MovieClip
        {
            return this;
        }// end function

        public function show(param1:String, param2:int) : void
        {
            if (param2 > 9)
            {
                param2 = 9;
            }
            var _loc_3:* = param2 * 10;
            _loc_3 = Math.PI / 180 * _loc_3;
            _loc_3 = 0.12 - Math.sin(_loc_3) / 10;
            var _loc_4:Object = {message:param1, speed:_loc_3};
            this._aryMessage.push(_loc_4);
            this._NoticeText.htmlText = (this._aryMessage[0] as Object)["message"];
            this._speed = (this._aryMessage[0] as Object)["speed"];
            if (!this.blnEnterFrame)
            {
                this.addEventListener(Event.ENTER_FRAME, this.enterFrame);
            }
            return;
        }// end function

        private function enterFrame(event:Event) : void
        {
            var _loc_2:Object = null;
            this.blnEnterFrame = true;
            if (this._angle <= 1.5)
            {
                this._num = Math.sin(this._angle);
                this._Notice.alpha = this._num;
                this._NoticeText.alpha = this._num;
            }
            else
            {
                if (this._angle >= 2)
                {
                }
                if (this._angle <= 3.111)
                {
                    if (this._wait > 0)
                    {
                        this._wait = this._wait - this._speed;
                        return;
                    }
                    this._num = Math.sin(this._angle);
                    this._Notice.alpha = this._num;
                    this._NoticeText.alpha = this._num;
                }
                else if (this._angle > 3.1)
                {
                    this._aryMessage.shift();
                    this._angle = 0;
                    this._wait = 2;
                    if (this._aryMessage.length > 0)
                    {
                        _loc_2 = this._aryMessage[0] as Object;
                        this._NoticeText.htmlText = _loc_2["message"];
                        this._speed = _loc_2["speed"];
                    }
                    else
                    {
                        this.removeEventListener(Event.ENTER_FRAME, this.enterFrame);
                        this._Notice.alpha = 0;
                        this._NoticeText.alpha = 0;
                        this.blnEnterFrame = false;
                        this._onClose();
                    }
                    return;
                }
            }
            this._angle = this._angle + this._speed;
            return;
        }// end function

        public function set onClose(param1:Function) : void
        {
            this._onClose = param1;
            return;
        }// end function

    }
}
